package com.ropeok.service.impl;
import com.ropeok.dao.PrivilegeDao;
import com.ropeok.entity.Privilege;
import com.ropeok.service.PrivilegeService;
import org.mybatis.logging.Logger;
import org.mybatis.logging.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
 * @BelongsProject: task2
 * @BelongsPackage: com.ropeok.service
 * @Author: zhofeifan
 * @CreateTime: 2022-08-23  14:45
 * @Description: TODO
 * @Version: 1.0
 */
@Service("privilegeService")
public class PrivilegeServiceImpl implements PrivilegeService {
    private static Logger logger= LoggerFactory.getLogger(PrivilegeService.class);
    @Autowired
    private PrivilegeDao privilegeDao;
    /**
     * @description: service层实现类 根据ID查找权限记录
     * @author: zhoufeifan
     * @date: 2022/9/15 10:06
     * @param: [long]
     * @return: com.ropeok.entity.Privilege
            **/
    @Override
    public Privilege findPrivilegeByID(long id) {
        return  privilegeDao.findPrivilegeByID(id);
    }
    /**
     * @description:  增加权限
     * @author: zhoufeifan
     * @date: 2022/9/15 10:08
     * @param: [com.ropeok.entity.Privilege]
     * @return: int
     **/

    @Override
    @Transactional(rollbackFor = Throwable.class)
    public int addPrivilege(Privilege privilege) {
        return privilegeDao.addPrivilege(privilege);
    }
    /**
     * @description:  删除权限
     * @author: zhoufeifan
     * @date: 2022/9/15 10:08
     * @param: [long]
     * @return: int
     **/

    @Override
    @Transactional(rollbackFor = Throwable.class)
    public int deletePrivilege(long id) {
        return privilegeDao.deletePrivilege(id);
    }
    /**
     * @description: 更新权限
     * @author: zhoufeifan
     * @date: 2022/9/15 10:24
     * @param: [com.ropeok.entity.Privilege]
     * @return: java.lang.Integer
    **/

    @Override
    @Transactional(rollbackFor = Throwable.class)
    public Integer updatePrivilege(Privilege privilege) {
        return privilegeDao.updatePrivilege(privilege);
    }
    /**
     * @description: 获取权限列表
     * @author: zhoufeifan
     * @date: 2022/9/15 10:25
     * @param: []
     * @return: java.util.List<com.ropeok.entity.Privilege>
    **/
    @Override
    public List<Privilege> getPrivilegeList() {
        List<Privilege> privilegeList = privilegeDao.getPrivilegeList();
        return privilegeList;
    }
}
